package dev.ece.core.fog;

import org.lwjgl.opengl.GL20;
/**
 * 雾化信息位置坐标
 * @author 飘渺青衣
 * <b>E-mail：</b>3375758@qq.com
 */
public class FogLocationHandler {
	
	private int enableHandler;
	
	private int maxDistanceHandler;
	
	private int minDistanceHandler;
	
	private int colorHandler;
	
	private FogLocationHandler() {}
	
	public static FogLocationHandler newInstance(int program, String prefix) {
		FogLocationHandler handler = new FogLocationHandler();
		handler.enableHandler = GL20.glGetUniformLocation(program, prefix.concat("enable"));
		handler.maxDistanceHandler = GL20.glGetUniformLocation(program, prefix.concat("maxDistance"));
		handler.minDistanceHandler = GL20.glGetUniformLocation(program, prefix.concat("minDistance"));
		handler.colorHandler = GL20.glGetUniformLocation(program, prefix.concat("color"));
		return handler;
	}
	
	public void glUniform(Fog fog) {
		fog.glUniform(this);
	}
	
	public int getEnableHandler() {
		return enableHandler;
	}

	public int getMaxDistanceHandler() {
		return maxDistanceHandler;
	}

	public int getMinDistanceHandler() {
		return minDistanceHandler;
	}

	public int getColorHandler() {
		return colorHandler;
	}
	
	public void clearup() {
		GL20.glDeleteShader(enableHandler);
		GL20.glDeleteShader(maxDistanceHandler);
		GL20.glDeleteShader(minDistanceHandler);
		GL20.glDeleteShader(colorHandler);
	}
	
}
